package cn.itcast.dmp.report

import cn.itcast.dmp.config.AppConfigHelper
import cn.itcast.dmp.process.ReportProcessor
import org.apache.spark
import org.apache.spark.sql.DataFrame

object ReportAdsChannelProcessor  extends  ReportProcessor{
  override def targetTableName: String = {
    AppConfigHelper.REPORT_ADS_CHANNEL_TABLE_NAME
  }

  override def targetTableKeys: Seq[String] = {
    Seq("report_date", "channelid")
  }

  override def realProcessData(odsDF: DataFrame): DataFrame ={
    val spark = odsDF.sparkSession
    // TODO: 此处使用SQL分析，所以先注册为临时视图，再编写SQL分析
    odsDF.createOrReplaceTempView("view_temp_ods")
    val reportRateDF: DataFrame = spark.sql(
      // ReportSQLConstant.reportAdsRegionKpiWithSQL("view_temp_ods")
      ReportSQLConstant.reportAdsKpiWithSQL("view_temp_ods", Seq("channelid"))
    )

    // 返回统计报表结果即可
    reportRateDF
  }



}
